<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <input type="text" class="user" placeholder="用户名">
    <br>
    <input type="text" class="email" placeholder="邮箱">
    <br>
    <input type="text" class="phone" placeholder="手机号">
    <br>
    <input type="text" class="pwd" placeholder="密码">
    <br>
    <button>注册</button>

    <script>

        // 手机号唯一   直接存对象
        // const obj = {
        //     user: 'yy',
        //     email: '28@qq.com',
        //     phone: 1888888,
        //     pwd: 666
        // }


        // localStorage.setItem('1888888', JSON.stringify(obj));


        // const res = JSON.parse(localStorage.getItem('1888888'));
        // console.log(res);

        document.querySelector('button').onclick = function () {
            const username = document.querySelector('.user').value;
            const password = document.querySelector('.pwd').value;
            const email = document.querySelector('.email').value;
            const phone = document.querySelector('.phone').value;

            // const obj = {
            //     username : username ,
            //     password : password ,
            //     email : email ,
            //     phone : phone
            // }
            const obj = { username, password, phone, email };
            localStorage.setItem(phone, JSON.stringify(obj));

            // document.cookie = `${phone}=${JSON.stringify(obj)}`
        }


    </script>

</body>

</html>